package ch06.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String opr = req.getParameter("opr");
        switch (opr){
            case "add":
                System.out.println("user>>>>>>>>>>>add");
                req.getRequestDispatcher("add.jsp").forward(req,resp);
                break;
            case "del":
                System.out.println("user>>>>>>>>>>>del");
                break;
            case "update":
                System.out.println("user>>>>>>>>>>>update");
                break;
            case "query":
                System.out.println("user>>>>>>>>>>>query");
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
